package com.atguigu.java8.datetime;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

// 解决SimpleDateFormat线程安全问题
public class DateFormatThreadLocal {

    private static final ThreadLocal<SimpleDateFormat> threadLocal =
            ThreadLocal.withInitial(() -> new SimpleDateFormat("yyyy-MM-dd"));

    public static Date convert(String value) throws ParseException {
        return threadLocal.get().parse(value);
    }

}
